/* eslint-disable @typescript-eslint/no-explicit-any */
/*
 *  Copyright 2021 Collate
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  http://www.apache.org/licenses/LICENSE-2.0
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

 /**
 * Create Storage Service entity request
 */
export interface CreateStorageService {
    connection?: StorageConnection;
    /**
     * Fully qualified name of the domain the Storage Service belongs to.
     */
    dataAssetDir?: string;
    /**
     * List of fully qualified names of data products this entity is part of.
     */
    dataProducts?: string[];
    /**
     * Description of storage service entity.
     */
    description?: string;
    /**
     * Display Name that identifies this storage service. It could be title or label from the
     * source services.
     */
    displayName?: string;
    /**
     * Fully qualified name of the domain the Storage Service belongs to.
     */
    domain?: string;
    /**
     * Name that identifies the this entity instance uniquely
     */
    name: string;
    /**
     * Owner of this object store service.
     */
    owner?:      EntityReference;
    serviceType: StorageServiceType;
    /**
     * Tags for this Object Store Service.
     */
    tags?: TagLabel[];
}

/**
 * Storage Connection.
 */
export interface StorageConnection {
    config?: Connection;
}

/**
 * S3 Connection.
 *
 * ADLS Connection.
 *
 * GCS Connection.
 *
 * Custom Storage Service connection to build a source that is not supported by OpenMetadata
 * yet.
 */
export interface Connection {
    awsConfig?: AWSCredentials;
    /**
     * Bucket Names of the data source.
     */
    bucketNames?:                string[];
    connectionArguments?:        { [key: string]: any };
    connectionOptions?:          { [key: string]: string };
    supportsMetadataExtraction?: boolean;
    /**
     * Service Type
     *
     * Custom storage service type
     */
    type?: StorageServiceType;
    /**
     * Azure Credentials
     *
     * GCP Credentials
     */
    credentials?: Credentials;
    /**
     * Source Python Class Name to instantiated by the ingestion workflow
     */
    sourcePythonClass?: string;
}

/**
 * AWS凭据配置
 */
export interface AWSCredentials {
    /**
     * 要假设的角色的Amazon资源名称（ARN），在假设角色的情况下，这是必需的字段
     */
    assumeRoleArn?: string;
    /**
     * 假定角色会话的标识符，在同一角色由不同主体或出于不同原因假定时，使用角色会话名称唯一标识会话，在假设角色的情况下，这是必需的字段
     */
    assumeRoleSessionName?: string;
    /**
     * 要假设的角色的Amazon资源名称（ARN），在假设角色的情况下，这是可选的字段
     */
    assumeRoleSourceIdentity?: string;
    /**
     * AWS访问密钥ID
     */
    awsAccessKeyId?: string;
    /**
     * AAWS区域
     */
    awsRegion: string;
    /**
     * AWS秘密访问密钥
     */
    awsSecretAccessKey?: string;
    /**
     * AWS会话令牌
     */
    awsSessionToken?: string;
    /**
     * AWS的终端点URL
     */
    endPointURL?: string;
    /**
     * 与boto会话一起使用的配置文件的名称
     */
    profileName?: string;
}

/**
 * Azure Credentials
 *
 * Azure Datalake凭据
 *
 * GCP Credentials
 *
 * GCP凭据配置
 */
export interface Credentials {
    /**
     * 您的存储账户的账户名称
     */
    accountName?: string;
    /**
     * 您的服务主体应用程序ID（客户端ID）
     */
    clientId?: string;
    /**
     * 您的服务主体密码（客户端密钥）
     */
    clientSecret?: string;
    /**
     * Scopes to get access token, for e.g. api://6dfX33ab-XXXX-49df-XXXX-3459eX817d3e/.default
     */
    scopes?: string;
    /**
     * Azure订阅的租户ID
     */
    tenantId?: string;
    /**
     * Key Vault Name
     */
    vaultName?: string;
    /**
     * 我们支持通过GCP凭据值或GCP凭据路径两种方式进行GCP身份验证
     */
    gcpConfig?: Gcp | string;
    /**
     * 我们启用经过身份验证的服务帐户来冒充另一个服务帐户
     */
    gcpImpersonateServiceAccount?: GCPImpersonateServiceAccountValues;
}

/**
 * 传递GCP提供的原始凭据值
 *
 * Pass the raw credential values provided by GCP
 */
export interface Gcp {
    /**
     * Google Cloud认证提供程序证书URL
     */
    authProviderX509CertUrl?: string;
    /**
     * Google Cloud认证URI
     */
    authUri?: string;
    /**
     * Google Cloud电子邮件
     */
    clientEmail?: string;
    /**
     * Google Cloud客户端ID
     */
    clientId?: string;
    /**
     * Google Cloud客户端证书URI
     */
    clientX509CertUrl?: string;
    /**
     * Google Cloud私钥
     */
    privateKey?: string;
    /**
     * Google Cloud私钥ID
     */
    privateKeyId?: string;
    /**
     * 项目ID
     */
    projectId?: string[] | string;
    /**
     * Google Cloud令牌URI
     */
    tokenUri?: string;
    /**
     * Google Cloud Platform帐户类型
     */
    type?: string;
    /**
     * Google Security Token Service audience which contains the resource name for the workload
     * identity pool and the provider identifier in that pool.
     */
    audience?: string;
    /**
     * This object defines the mechanism used to retrieve the external credential from the local
     * environment so that it can be exchanged for a GCP access token via the STS endpoint
     */
    credentialSource?: { [key: string]: string };
    /**
     * Google Cloud Platform account type.
     */
    externalType?: string;
    /**
     * Google Security Token Service subject token type based on the OAuth 2.0 token exchange
     * spec.
     */
    subjectTokenType?: string;
    /**
     * Google Security Token Service token exchange endpoint.
     */
    tokenURL?: string;
    [property: string]: any;
}

/**
 * 我们启用经过身份验证的服务帐户来冒充另一个服务帐户
 *
 * 传递用于冒充Google Cloud服务帐户的值
 */
export interface GCPImpersonateServiceAccountValues {
    /**
     * 被冒充的服务帐户电子邮件
     */
    impersonateServiceAccount?: string;
    /**
     * 委派凭证应有效的秒数
     */
    lifetime?: number;
    [property: string]: any;
}

/**
 * Service Type
 *
 * S3 service type
 *
 * ADLS service type
 *
 * Gcs service type
 *
 * Custom storage service type
 *
 * Type of storage service such as S3, GFS, AZURE...
 */
export enum StorageServiceType {
    Adls = "ADLS",
    CustomStorage = "CustomStorage",
    Gcs = "GCS",
    S3 = "S3",
}

/**
 * Owner of this object store service.
 *
 * This schema defines the EntityReference type used for referencing an entity.
 * EntityReference is used for capturing relationships from one entity to another. For
 * example, a table has an attribute called database of type EntityReference that captures
 * the relationship of a table `belongs to a` database.
 */
export interface EntityReference {
    /**
     * If true the entity referred to has been soft-deleted.
     */
    deleted?: boolean;
    /**
     * Optional description of entity.
     */
    description?: string;
    /**
     * Display Name that identifies this entity.
     */
    displayName?: string;
    /**
     * Fully qualified name of the entity instance. For entities such as tables, databases
     * fullyQualifiedName is returned in this field. For entities that don't have name hierarchy
     * such as `user` and `team` this will be same as the `name` field.
     */
    fullyQualifiedName?: string;
    /**
     * Link to the entity resource.
     */
    href?: string;
    /**
     * Unique identifier that identifies an entity instance.
     */
    id: string;
    /**
     * If true the relationship indicated by this entity reference is inherited from the parent
     * entity.
     */
    inherited?: boolean;
    /**
     * Name of the entity instance.
     */
    name?: string;
    /**
     * Entity type/class name - Examples: `database`, `table`, `metrics`, `databaseService`,
     * `dashboardService`...
     */
    type: string;
}

/**
 * 此模式定义了用于使用标签标记实体的标签类型
 */
export interface TagLabel {
    /**
     * 标签标签的描述
     */
    description?: string;
    /**
     * 标识此标签的显示名称
     */
    displayName?: string;
    /**
     * 到标签资源的链接
     */
    href?: string;
    /**
     *
     * 标签类型描述标签标签是如何应用的，'Manual'表示标签标签是由人员应用的。'Derived'表示使用关联的标签关系导出了标签标签（有关详细信息，请参见Classification.json）。'Propagated`表示标签标签是根据血统从上游传播的。'Automated'在使用工具确定标签标签时使用。
     */
    labelType: LabelType;
    /**
     * 标签或词汇术语的名称
     */
    name?: string;
    /**
     * 标签来自标签还是词汇表
     */
    source: TagSource;
    /**
     * 'Suggested'状态在用户或工具建议标签标签时使用。实体的所有者必须在将其标记为'Confirmed'之前确认建议的标签
     */
    state:  State;
    style?: Style;
    tagFQN: string;
}

/**
 *
 * 标签类型描述标签标签是如何应用的，'Manual'表示标签标签是由人员应用的。'Derived'表示使用关联的标签关系导出了标签标签（有关详细信息，请参见Classification.json）。'Propagated`表示标签标签是根据血统从上游传播的。'Automated'在使用工具确定标签标签时使用。
 */
export enum LabelType {
    Automated = "Automated",
    Derived = "Derived",
    Manual = "Manual",
    Propagated = "Propagated",
}

/**
 * 标签来自标签还是词汇表
 */
export enum TagSource {
    Classification = "Classification",
    Glossary = "Glossary",
}

/**
 * 'Suggested'状态在用户或工具建议标签标签时使用。实体的所有者必须在将其标记为'Confirmed'之前确认建议的标签
 */
export enum State {
    Confirmed = "Confirmed",
    Suggested = "Suggested",
}

/**
 * UI Style is used to associate a color code and/or icon to entity to customize the look of
 * that entity in UI.
 */
export interface Style {
    /**
     * Hex Color Code to mark an entity such as GlossaryTerm, Tag, Domain or Data Product.
     */
    color?: string;
    /**
     * An icon to associate with GlossaryTerm, Tag, Domain or Data Product.
     */
    iconURL?: string;
}
